<?php  
class ControllerModuleNewscategory extends Controller {
	protected function index() {
		$this->language->load('module/news');
		$this->load->model('fido/news');
		
    $this->data['heading_title'] = $this->language->get('heading_category_title');
		
		if (isset($this->request->get['path'])) {
			$parts = explode('_', (string)$this->request->get['path']);
		} else {
			$parts = array();
		}
		
		if (isset($parts[0])) {
			$this->data['category_id'] = $parts[0];
		} else {
			$this->data['category_id'] = 0;
		}
		
		$this->data['categories'] = array();
					
		$categories = $this->model_fido_news->getSelectCategory(); 
		
		$cat_data = array();
		foreach ($categories as $cat_id => $cat_name) {				
				$cat_data[] = array(
					'category_id' => $cat_id,
					'name'        => $cat_name,
					'href'        => $this->url->link('information/news', 'path=' . $cat_id)	
				);					
		}
		
		$this->data['categories'] = $cat_data;
		
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/newscategory.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/module/newscategory.tpl';
		} else {
			$this->template = 'default/template/module/newscategory.tpl';
		}
		
		$this->render();
  	}
}
?>